package zhihuilan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import zhihuilan.entity.MyContentBanner;
import zhihuilan.mapper.MyContentBannerMapper;
import zhihuilan.params.query.MyContentBannerQueryParam;
import zhihuilan.service.MyContentBannerService;

import java.util.List;

@Service
public class MyContentBannerServiceImpl extends ServiceImpl<MyContentBannerMapper, MyContentBanner> implements MyContentBannerService {

    @Override
    public List<MyContentBanner> selectList(MyContentBannerQueryParam queryParam) {
        if(ObjectUtils.isEmpty(queryParam)){
            return null;
        }
        QueryWrapper<MyContentBanner> queryWrapper = new QueryWrapper<>();
        if(ObjectUtils.isEmpty(queryParam.getType())){
            queryWrapper.eq("type",2);
        }else{
            queryWrapper.eq("type",queryParam.getType());
        }
        if(ObjectUtils.isEmpty(queryParam.getStatus())){
            queryWrapper.eq("status",1);
        }
        else{
            queryWrapper.eq("status",queryParam.getStatus());
        }
        if(!ObjectUtils.isEmpty(queryParam.getDistrictid())){
            queryWrapper.or().likeRight("districtid",queryParam.getDistrictid());
        }
        queryWrapper.orderByDesc("sort");
        return this.baseMapper.selectList(queryWrapper);
    }
}
